<?php
// 登录控制器
class LoginAction extends Action {
	/**
	 * [index description]登录页面跳转
	 * @return [type] [description]
	 */
    public function index(){
		$this->display('Login:login');
    }

    /**
	 * [login description]用户登录
	 * @return [type] [description]
	 */
	public function loginPost(){
		$employe_work_id=strval(trim($_POST['employe_work_id']));
		$employe_password=strval(md5(trim($_POST['employe_password'])));
		$employe=M('Employe');
		$result=$employe->where("employe_work_id ='".$employe_work_id."' and employe_password ='".$employe_password."'")->find();
		if($result){
				$employe_id=$employe->where("employe_work_id ='".$employe_work_id."'")->getField('employe_id');
				session('employe_id',$employe_id);
				cookie('employe_id',$employe_id,3600);
				echo 'ok';
			}
			else{
				echo '用户名或密码错误！';
			}
	}

	/**
	 * [loginout description]退出系统
	 * @return [type] [description]
	 */
	public function loginout(){
		session('employe_id',null);
		cookie('employe_id',null,3600);
		$url=U('Home/Login/index/');
		redirect($url,0, '跳转中...');
	}

}